package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Tag;
import cn.wolfcode.trip.base.mapper.TagMapper;
import cn.wolfcode.trip.base.service.ITagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2018/11/13.
 */
@Service
public class TagServiceImpl implements ITagService {

    @Autowired
    private TagMapper tagMapper;

    @Override
    public void save(Tag tag) {
        tagMapper.insert(tag);
    }

    @Override
    public List<Tag> listByCommentId(Long id) {

        return tagMapper.selectByCommentId(id);
    }

    @Override
    public List<Tag> listByStrategyId(Long strategyId) {
        List<Tag> customizedTags= tagMapper.listCustomizedTagById(strategyId);
        List<Tag> statedTags = tagMapper.listStatedTagById(strategyId);
        for (int i = 0; i < customizedTags.size(); i++) {
            statedTags.add(customizedTags.get(i));
        }
        return statedTags;
    }
}
